package com.peanut.wapp.persist.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.peanut.wapp.model.NewsBean;
import com.peanut.wapp.persist.NewsDao;

@Repository
public class NewsImpl extends BaseImpl implements NewsDao {
	
	final String NAME_SPACE = NAME_SPACE_HEADER + ".NewsMapper";

	@Override
	public int selectCount() {
		return sqlSessionTemplate.selectOne(NAME_SPACE + ".selectCount");
	}

	@Override
	public List<NewsBean> selectList(int page, int pageSize) {
		Map<String, Object> where = new HashMap<>();
		where.put("start", page * pageSize);
		where.put("length", pageSize);
		return sqlSessionTemplate.selectList(NAME_SPACE + ".selectList", where);
	
	}

	@Override
	public NewsBean selectOneById(String nid) {
		return sqlSessionTemplate.selectOne(NAME_SPACE + ".selectOneById", nid);
	}



}
